package routers

import (
	"filfoxexporter/controllers"
	"net/http"

	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {
	r := gin.Default()

	r.Static("/statics", "./statics")
	r.LoadHTMLGlob("./htmls/*")

	//if mode := gin.Mode(); mode == gin.DebugMode {
	//	r.LoadHTMLGlob(filepath.Join(os.Getenv("GOPATH"), "afilfoxexporter/htmls/*"))
	//} else {
	//	r.LoadHTMLGlob("./htmls/*")
	//}

	r.GET("/test", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "test",
		})
	})

	r.GET("/", controllers.Index)
	r.POST("/message", controllers.Message)
	r.POST("/trans", controllers.Trans)
	//r.POST("/download", controllers.Download)
	r.StaticFS("/download", http.Dir("./data"))

	return r
}
